<?php
/*
	插件概览
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$plugin_name = $_RQ['basicname'] ? $_RQ['basicname'] : '';
if($_RQ['op']=='get'){
	$live=pdo_get('core_account_wxapp_live',array('uniacid'=>$_SESSION['uniacid'],'pluginname'=>'jy_liveshop'));
	$live_id=$live['id'];
	//显示统计数据
		$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
		$mounthtime =  mktime(0,0,0,date('m'),1,date('Y'));
		$access=array();
		$access['room_day']=pdo_count('core_account_wxapp_live_rooms',array('uniacid'=>$_SESSION['uniacid'],'live_id'=>$live_id,'createtime >'=>$daytime));
		$access['look_day']=pdo_count('core_account_wxapp_live_looklog',array('uniacid'=>$_SESSION['uniacid'],'live_id'=>$live_id,'createtime >'=>$daytime));
		$access['get_day']=pdo_count('core_account_wxapp_live_getlog',array('uniacid'=>$_SESSION['uniacid'],'live_id'=>$live_id,'createtime >'=>$daytime));
		$access['room_all']=pdo_count('core_account_wxapp_live_looklog',array('uniacid'=>$_SESSION['uniacid'],'live_id'=>$live_id));
		$access['look_all']=pdo_count('core_account_wxapp_live_looklog',array('uniacid'=>$_SESSION['uniacid'],'live_id'=>$live_id));
		$access['get_all']=pdo_count('core_account_wxapp_live_looklog',array('uniacid'=>$_SESSION['uniacid'],'live_id'=>$live_id));
		$access['goods_day']=pdo_count('core_account_wxapp_live_goods',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime));
		$access['order_day']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'api_data like'=>'%jy_liveshoproomid%','createtime >'=>$daytime));
		$access['order_dayfee']=pdo_getsum('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'api_data like'=>'%jy_liveshoproomid%','createtime >'=>$daytime),'price');
		$access['goods_all']=pdo_count('core_account_wxapp_live_goods',array('uniacid'=>$_SESSION['uniacid']));
		$access['order_all']=pdo_count('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'api_data like'=>'%jy_liveshoproomid%'));
		$access['order_allfee']=pdo_getsum('jy_weishop_order',array('uniacid'=>$_SESSION['uniacid'],'api_data like'=>'%jy_liveshoproomid%'),'price');
		//月份
		for($i=0;$i<12;$i++){
				if($i==0){
					$yuestart = mktime(0,0,0,date('m'),1,date('Y'));
					$yueend = time();
					
				}else{
					$yuestart = mktime(0,0,0,date('m')-$i,1,date('Y'));
					$yueend = mktime(0,0,0,date('m')-$i+1,1,date('Y'));
				}
				$params=array('uniacid'=>$_SESSION['uniacid'],'api_data like'=>'%jy_liveshoproomid%');
				$params['createtime between']=array($yuestart,$yueend);
				$month12[$i] = date('Y-m',strtotime('-'.$i.' month'));
				//$monthaccess[]=pdo_count('core_access_log',$params);
				$accessline[$i]=pdo_count('jy_weishop_order',$params);
				//$monthcredit2[]=pdo_getsum('core_members',$params,'credit2');
		}
		$accessline=array_reverse($accessline);
		$month12=array_reverse($month12);
		$return['htmls']=array(
				array('type'=>'data','one_num'=>2,'title'=>'直播今日/总数据指标','datas'=>array(
					array('title'=>'直播间','num'=>2,'data'=>array($access['room_day'],$access['room_all'])),
					array('title'=>'商品数据','num'=>2,'data'=>array($access['goods_day'],$access['goods_all'])),
					array('title'=>'看直播数据','num'=>2,'data'=>array($access['look_day'],$access['look_all'])),
					array('title'=>'活动领奖数据','num'=>2,'data'=>array($access['get_day'],$access['get_all'])),
					array('title'=>'直播间销量','num'=>2,'data'=>array($access['order_day'],$access['order_all'])),
					array('title'=>'直播间业绩','num'=>2,'data'=>array($access['order_dayfee'],$access['order_allfee'])),
				)),
				array('type'=>'echarts_arealine','ecid'=>'mobile','title'=>'月度直播业绩数据','datas'=>array(
					'datas'=>array(
						array('name'=>'访问量','value'=>$accessline),
					),
					'xdatas'=>$month12,
				)),
	);
	exi($return);
}